---
title: Microsoft SQL Server
sidebarTitle: Microsoft SQL Server
---

This is the implementation of the Microsoft SQL Server data handler for MindsDB.

[Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server) is a relational database management system developed by Microsoft. As a database server, it stores and retrieves data as requested by other software applications, which may run either on the same computer or on another computer across a network.

## Prerequisites

Before proceeding, ensure the following prerequisites are met:

1. Install MindsDB [locally via Docker](https://docs.mindsdb.com/setup/self-hosted/docker) or use [MindsDB Cloud](https://cloud.mindsdb.com/).
2. To connect Microsoft SQL Server to MindsDB, install the required dependencies following [this instruction](/setup/self-hosted/docker#install-dependencies).
3. Install or ensure access to Microsoft SQL Server.

## Implementation

This handler is implemented using `pymssql`, the Python language extension module that provides access to Microsoft SQL Server from Python scripts.

The required arguments to establish a connection are as follows:

* `host` is the host name or IP address.
* `port` is the port used to make TCP/IP connection.
* `database` is the database name.
* `user` is the database user.
* `password` is the database password.

## Usage

In order to make use of this handler and connect to the SQL Server database in MindsDB, the following syntax can be used:

```sql
CREATE DATABASE mssql_datasource
WITH
    engine = 'mssql',
    parameters = {
      "host": "127.0.0.1",
      "port": 1433,
      "database": "master",
      "user": "sa",
      "password": "password"
    };
```

You can use this established connection to query your table as follows:

```sql
SELECT *
FROM mssql_datasource.example_tbl;
```
